<%@page import="com.cositas.dulces.lp.promo2012.utils.PromotionUtils"%><%--
--%><%@page import="com.google.appengine.api.datastore.Entity"%><%--
--%><%@page import="com.restfb.types.User"%><%--
--%><%@page import="java.util.Collections"%><%--
--%><%@page import="java.util.ArrayList"%><%--
--%><%@page import="java.util.List"%><%--
--%><%@page import="java.io.PrintWriter"%><%--
--%><%@page import="org.apache.commons.lang.StringUtils"%><%--
--%><%@page import="com.cositas.dulces.lp.fb.SignedRequest"%><%--
--%><%
try {
	String signedReqString = request.getParameter("signed_request");
	SignedRequest sessionSignedRequest = (SignedRequest)request.getSession().getAttribute("SR");
	boolean fromSession = false;
	if (signedReqString == null && sessionSignedRequest == null) { %><%@ include file="ups.jsp" %><% return;} 
	SignedRequest sr = null;
	if (StringUtils.isEmpty(signedReqString)) {
		sr = sessionSignedRequest;
		fromSession = true;
		signedReqString = sessionSignedRequest.getSignedRequest();
	} else {
		sr = new SignedRequest(signedReqString);
	}
	if (sr == null) { %><%@ include file="ups.jsp" %><%	return;}  
	if (!sr.isFan()) { %><%@ include file="onlyforfans.jsp" %><%	return;}  
	if (!sr.hasOAuth()) { %><%@ include file="redirect.jsp" %><% return;}
	User user = sr.getFacebookUser(); 
	Entity entity = PromotionUtils.getParticipant(sr.getParticipantKey());
	String sub = sr.getAppData();%>
	<%@ include file="puzzle.jspf" %>
<%
} catch (Exception e) {
	e.printStackTrace(new PrintWriter(out));
}%>